feat: Implement FuncDoTaskBuilder to also cover raise and tryCatch#1322
feat: Implement FuncDoTaskBuilder to also cover raise and tryCatch#1322matheusandre1 wants to merge 2 commits intoserverlessworkflow:mainfrom
Conversation
|
take a look, @domhanak.... |
|
Hi @matheusandre1 is this ready for review? |
There was a problem hiding this comment.
Pull request overview
This PR extends the experimental FuncWorkflowBuilder / FuncDoTaskBuilder fluent API so function-based workflows can include raise() and tryCatch() tasks (per #1304), avoiding the need to fall back to JQ for these constructs.
Changes:
- Add
raise(...)andtryCatch(...)support to the func “do” fluent surface (FuncDoFluent,FuncDoTaskBuilder,FuncTaskItemListBuilder) and provide matchingFuncDSLhelpers. - Introduce
FuncRaiseTaskBuilderandFuncTryTaskBuilderto build the corresponding spec task structures. - Add a JUnit test validating
raiseandtry/catchcompilation throughFuncWorkflowBuilder.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| experimental/fluent/func/src/test/java/io/serverlessworkflow/fluent/func/FuncDSLTest.java | Adds coverage ensuring raise and tryCatch tasks are emitted correctly via FuncWorkflowBuilder. |
| experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/spi/FuncDoFluent.java | Extends the func “do” fluent interface to include raise and try/catch task fluent APIs. |
| experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/dsl/FuncDSL.java | Adds FuncDSL.raise(...) and FuncDSL.tryCatch(...) task configurer helpers. |
| experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncTryTaskBuilder.java | New builder for try/catch tasks (try handler + catch handler + retry/errors/backoff helpers). |
| experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncTaskItemListBuilder.java | Implements list-level raise and tryCatch task appenders. |
| experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncRaiseTaskBuilder.java | New builder for raise tasks. |
| experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncDoTaskBuilder.java | Wires raise and tryCatch through the workflow “do” builder to the underlying list builder. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Matheus Andre <matheusandr2@gmail.com> Signed-off-by: Matheus André <matheusandr2@gmail.com>
cc8dd6f to
4ea02b7
Compare
mcruzdev
left a comment
There was a problem hiding this comment.
It looks great @matheusandre1, please, could you add a test that demostrate a workflow running? Inside src/test/java/io/serverlessworkflow/fluent/test?
Where we are testing all the FuncDSL methods |
Signed-off-by: Matheus André <matheusandr2@gmail.com>
aec1d6c to
dffd1f8
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public class FuncRaiseTaskBuilder extends TaskBaseBuilder<FuncRaiseTaskBuilder> | ||
| implements FuncTaskTransformations<FuncRaiseTaskBuilder>, | ||
| ConditionalTaskBuilder<FuncRaiseTaskBuilder> { | ||
|
|
||
| private final RaiseTask raiseTask; | ||
|
|
||
| FuncRaiseTaskBuilder() { | ||
| this.raiseTask = new RaiseTask(); | ||
| setTask(this.raiseTask); | ||
| } |
There was a problem hiding this comment.
(Optional) FuncRaiseTaskBuilder closely mirrors fluent/spec RaiseTaskBuilder. This duplication can make future spec-aligned changes easy to miss in one place. If feasible, consider refactoring so the func DSL reuses the spec builder implementation (e.g., by sharing a common base/helper or making the spec builder constructor extensible).
| public class FuncTryTaskBuilder extends TaskBaseBuilder<FuncTryTaskBuilder> | ||
| implements FuncTaskTransformations<FuncTryTaskBuilder>, | ||
| ConditionalTaskBuilder<FuncTryTaskBuilder> { | ||
|
|
||
| private final TryTask tryTask; | ||
|
|
||
| FuncTryTaskBuilder() { | ||
| this.tryTask = new TryTask(); | ||
| setTask(this.tryTask); | ||
| } |
There was a problem hiding this comment.
(Optional) FuncTryTaskBuilder largely duplicates fluent/spec TryTaskBuilder (including nested retry/backoff/catch builders). This increases maintenance overhead and the risk of behavior drifting between spec and func DSL over time. If practical, consider extracting shared helpers/builders or refactoring to reuse the spec builder implementation so both stay in sync.
|
@mcruzdev , Ignore review copilot or can I do this refactor? |
|
I'm doing something similar, I'll send it shortly. |
Many thanks for submitting your Pull Request ❤️!
What this PR does / why we need it: draft to Closes: #1304
Special notes for reviewers:
Additional information (if needed):